<?php
namespace app\blog\controller\admin;

use app\common\controller\Back;

class Channel extends Back
{
    protected function initialize()
    {
        parent::initialize();
    }
    
    public function index()
    {
        $form = xfFormCreate([
            'name'         => 'blogAdminChannelIndex',
            'action'       => xfUrl('blog/admin.channel/update'),
            'items'        => model('blog/Channel','form')->items(config('channel.')),
            'reset'        => '重置',
            'class_button' => 'text-left',
        ]);

        $this->assign('form',$form);

        $this->assign($this->site);

        return $this->fetch();
    }

    public function update()
    {
        $post = xfArrayFilter(input('post.'), model('blog/Channel','form')->keys());

        $post = array_merge(config('channel.'),$post);

        $this->configSave('./config/blog/channel.php', $post, 'blog/admin.channel/index');
    }
}